﻿namespace RuoVea.Swms.Web.Controllers;

/// <summary>
/// 表备注 控制器
/// </summary>
[Authorize(Roles = "None")]
public partial class InventoryHistoryController : Controller
{
    /// <summary>
    /// 
    /// </summary>
    private readonly InventoryHistoryService _thisService;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="thisService"></param> 
    public InventoryHistoryController(InventoryHistoryService thisService)
    {
        _thisService = thisService;
    }

    public IActionResult Index()
    {
        return View();
    }

    /// <summary>
    /// 查询所有/分页
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    [HttpPost("inventoryHistory/pages")]
    public async Task<RestfulResult<PageResult<WmsInventoryHistory>>> GetPagesAsync()
    {
        using var sr = new StreamReader(Request.Body);
        string dataStr = await sr.ReadToEndAsync();
        if (Request.Body.CanSeek)
            Request.Body.Position = 0;
        if (string.IsNullOrWhiteSpace(dataStr))
            throw new Exception("未提供上传数据。请在Request.Body中携带上传数据。");
        PageParam? data = JsonConvert.DeserializeObject<PageParam>(dataStr);
        data ??= new PageParam { PageNo = 1, PageSize = 10 };

        var query = await _thisService.GetPagesAsync(data);
        return query;
    }
}

